<template>
    <a-form ref="formRef" :model="formData">
        <a-form-item field="id" label="ID" label-col-flex="auto" :label-col-style="{ width: '85px' }">
            <a-input-number v-model="formData.id" placeholder="请输入ID" readonly />
        </a-form-item>
        <a-form-item field="phone" label="手机号" label-col-flex="auto" :label-col-style="{ width: '85px' }">
            <a-input v-model="formData.phone" placeholder="请输入手机号" readonly />
        </a-form-item>
        <a-form-item field="type" label="类型" label-col-flex="auto" :label-col-style="{ width: '85px' }">
            <a-radio-group v-model="formData.type">
                <a-radio :value="1">增加</a-radio>
                <a-radio :value="2">减少</a-radio>
            </a-radio-group>
        </a-form-item>
        <a-form-item field="money" label="金额" label-col-flex="auto" :label-col-style="{ width: '85px' }">
            <a-input-number v-model="formData.money" placeholder="请输入金额" />
        </a-form-item>
    </a-form>
</template>
<script setup lang="ts">
import { ref } from "vue";
import type { Ref } from "vue"
import request from '@/api/users'
import { Message } from "@arco-design/web-vue";
const emit = defineEmits<{
    refreshList
}>();
const props = defineProps<{
    id: string | number
}>();
interface IPoint {
    id: number
    type: number,
    phone: string,
    money: number
}
const formData: Ref<IPoint> = ref({
    id: 0,
    type: 1,
    phone: '',
    money: 0
});
const getDeta = async () => {
    let { data: { data } } = await request.get_deta(props.id);
    formData.value = data;
    formData.value.type = 1;
};
getDeta();

const submit = async () => {
    await request.save(formData.value);
    Message.success("保存成功");
    setTimeout(() => emit("refreshList"), 500);
};
defineExpose({ submit });
</script>